Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML][AIOps] Log rate analysis: ensure ability to sort on Log rate change #193501

Merged

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Sep 20, 2024

Summary

This PR

  • updates the LogRateAnalysisResultsTable to use EuiInMemoryTable to simplify sorting and pagination
  • adds sorting to Log rate change column
  • persists columns selected for viewing in the result view

Related meta issue: #187684

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 self-assigned this Sep 20, 2024
@alvarezmelissa87 alvarezmelissa87 marked this pull request as ready for review September 30, 2024 22:19
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner September 30, 2024 22:19
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@peteharverson peteharverson added Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis v9.0.0 v8.16.0 backport:version Backport to applied version labels labels Oct 1, 2024
Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested latest changes and LGTM

@walterra
Copy link
Contributor

walterra commented Oct 1, 2024

The switch to in-memory-table causes a regression with syncing the table and histogram chart for hovering and pinning rows. On main the hovering/pinning acts on the items on display on the current table page only. This is no longer the case in this PR.

If nothing is hovered/pinned on the table, it should fall back to the first row of the current table page, highlight it and sync it with the histogram chart like this on main:

First page:

image

Second page:

image

In this PR it doesn't fall back to the first row:

image

On the second page of results, the fallback doesn't work again, because of all items passed on to the in-memory-table, there's still an item selected on the (invisible) first page and synced with the chart, so the histogram shown in the main chart doesn't match any item on the current page of the table:

image

@alvarezmelissa87
Copy link
Contributor Author

alvarezmelissa87 commented Oct 1, 2024

@peteharverson, @walterra
In light of the regression that @walterra found (thank you!) I switched back to the basic table (as any optimizations we get with the in memory table would be negated by the need to manually keep track of pages of items for the hover/pinning behavior to be fixed).

In order to keep the way we sort consistent with the changes made for log rate analysis for the contextual insight for observability, this PR now adds the logRateChangeSort to the table items using the same logic.
When sorting by Log rate change the table will now be sorted by this field. The messaging will look the same.

@peteharverson - touched on this a bit with Walter but this logic is not in line with keeping the rate change higher than just docs up/down from 0. Keeping this as until further discussion on sorting so the sorting is consistent across the board.

@alvarezmelissa87 alvarezmelissa87 added release_note:enhancement backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 1, 2024
@@ -123,6 +129,7 @@ export const LogRateAnalysisResultsTable: FC<LogRateAnalysisResultsTableProps> =
const itemCount = significantItems?.length ?? 0;

let items: SignificantItem[] = significantItems ?? [];
// console.log('--- SORT FIELD ---', sortField.props.children[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 7f0c33b

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with latest changes and LGTM

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To not rely on the REDUCTION_FACTOR, I'd like to suggest to change the sorting to use Number.POSITIVE_INFINITY instead of docCount when bgCount is zero. Then on top of that do a secondary sort on docCount. About the secondary sort I couldn't put an inline comment in the changed code because the place it needs to be done wasn't touched so far in this PR.

There is already a secondary sort in place for the p-value column, there we can add the other secondary sort. We need to do that for both ungrouped and grouped table here:

Regular table: https://github.com/elastic/kibana/blob/main/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table.tsx#L138
Grouped table: https://github.com/elastic/kibana/blob/main/x-pack/plugins/aiops/public/components/log_rate_analysis_results_table/log_rate_analysis_results_table_groups.tsx#L281

@@ -9,6 +9,8 @@ import { i18n } from '@kbn/i18n';
import { LOG_RATE_ANALYSIS_TYPE } from './log_rate_analysis_type';
import type { LogRateAnalysisType } from './log_rate_analysis_type';

const REDUCTION_FACTOR = 0.000001;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my suggestion using Number.POSITIVE_INFINITY and a secondary sort on docCount I hope we can avoid relying on this sort of magic factor, can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 7f0c33b and was able to remove that const.

const allSignificantItems = useMemo(() => {
return allItems.map((item) => ({
...item,
logRateChangeSort: item.bg_count > 0 ? item.doc_count / item.bg_count : item.doc_count,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest to use Number.POSITIVE_INFINITY instead of doc count when bg count is 0:

logRateChangeSort: item.bg_count > 0 ? item.doc_count / item.bg_count : Number.POSITIVE_INFINITY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use Number.POSITIVE_INFINITY in 7f0c33b

</>
),
render: (_, { pValue }) => {
name: isGroupsTable ? GroupImpactColumnName : ImpactColumnName, // content={isGroupsTable ? groupImpactMessage : impactMessage}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we can remove the comment?

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM, also tested the sorting 👍

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
aiops 551.9KB 552.7KB +845.0B
Unknown metric groups

API count

id before after diff
@kbn/ml-agg-utils 94 95 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit c18184a into elastic:main Oct 3, 2024
20 checks passed
@alvarezmelissa87 alvarezmelissa87 deleted the ml-log-rate-change-column branch October 3, 2024 16:40
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11166038208

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 3, 2024
…nge (elastic#193501)

## Summary

This PR
- updates the `LogRateAnalysisResultsTable` to use `EuiInMemoryTable` to
simplify sorting and pagination
- adds sorting to `Log rate change` column
- persists columns selected for viewing in the result view

Related meta issue: elastic#187684

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Elastic Machine <[email protected]>
(cherry picked from commit c18184a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 3, 2024
…te change (#193501) (#194862)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML][AIOps] Log rate analysis: ensure ability to sort on Log rate
change (#193501)](#193501)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Melissa
Alvarez","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-03T16:40:10Z","message":"[ML][AIOps]
Log rate analysis: ensure ability to sort on Log rate change
(#193501)\n\n## Summary\r\n\r\nThis PR \r\n- updates the
`LogRateAnalysisResultsTable` to use `EuiInMemoryTable` to\r\nsimplify
sorting and pagination\r\n- adds sorting to `Log rate change`
column\r\n- persists columns selected for viewing in the result
view\r\n\r\nRelated meta issue:
https://github.com/elastic/kibana/issues/187684\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"c18184ae26c4af3f203256b582790f5bf4e0f595","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement",":ml","v9.0.0","backport:prev-minor","Feature:ML/AIOps","v8.16.0","backport:version"],"title":"[ML][AIOps]
Log rate analysis: ensure ability to sort on Log rate
change","number":193501,"url":"https://github.com/elastic/kibana/pull/193501","mergeCommit":{"message":"[ML][AIOps]
Log rate analysis: ensure ability to sort on Log rate change
(#193501)\n\n## Summary\r\n\r\nThis PR \r\n- updates the
`LogRateAnalysisResultsTable` to use `EuiInMemoryTable` to\r\nsimplify
sorting and pagination\r\n- adds sorting to `Log rate change`
column\r\n- persists columns selected for viewing in the result
view\r\n\r\nRelated meta issue:
https://github.com/elastic/kibana/issues/187684\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"c18184ae26c4af3f203256b582790f5bf4e0f595"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193501","number":193501,"mergeCommit":{"message":"[ML][AIOps]
Log rate analysis: ensure ability to sort on Log rate change
(#193501)\n\n## Summary\r\n\r\nThis PR \r\n- updates the
`LogRateAnalysisResultsTable` to use `EuiInMemoryTable` to\r\nsimplify
sorting and pagination\r\n- adds sorting to `Log rate change`
column\r\n- persists columns selected for viewing in the result
view\r\n\r\nRelated meta issue:
https://github.com/elastic/kibana/issues/187684\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<[email protected]>","sha":"c18184ae26c4af3f203256b582790f5bf4e0f595"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Melissa Alvarez <[email protected]>
tiansivive pushed a commit to tiansivive/kibana that referenced this pull request Oct 7, 2024
…nge (elastic#193501)

## Summary

This PR 
- updates the `LogRateAnalysisResultsTable` to use `EuiInMemoryTable` to
simplify sorting and pagination
- adds sorting to `Log rate change` column
- persists columns selected for viewing in the result view

Related meta issue: elastic#187684

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) backport:version Backport to applied version labels Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis :ml release_note:enhancement v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants